#ifndef THE_ENCRYPTOR
#define THE_ENCRYPTOR

/*
 *  theEncryptor.h
 *  
 *
 *  Created by B. Jones on 14/01/2010.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

// Will wrap around openssl and do all encryption handling

#include <openssl/rsa.h>

class theEncryptor
{
public:
	theEncryptor();
	~theEncryptor();
	
	void blowfish(unsigned char *data, int data_len, int enc,int type=0);
	void generateRSAKeyPair(int bits = 2048);
	int publicEncrypt(unsigned char*,unsigned char*, int);
	int encryptSymmetricKey(unsigned char*, int);
	int privateDecrypt(unsigned char*,unsigned char*);
	int decryptSymmetricKey(unsigned char*);
	int rsaSize();
	void receivePublicKeyAndSetRSA(int, int bits=2048);
	void transmitPublicKey(int, int bits=2048);
	void generateRandomBlowfishKey(int=64 /* 512 bit */);
	void generateIV(int=16,int type=0);

	void receiveEncryptedSymmetricKey(int sock);
	void encryptAndSendSymmetricKey(int sock);

	void sendIvec(int sock, int type=0);
	void receiveIvec(int sock,int type=0);

	unsigned char symmetricKey[64];
	unsigned char ivec[16];
	unsigned char ivec_rec[16];
	unsigned char ivec_send[16];

private:
	
	RSA *rsa;
	
};

#endif
